#------------------------------------------------------------------------------
# iosVersion.pl
#   Plugin for MacRipper
#   Get the OS version
#
# Change history
#   20120605 [fpi] * released
#
# References
#
# copyright 2012 Francesco Picasso <francesco.picasso@gmail.com>
#------------------------------------------------------------------------------

package iosVersion;
use strict;

#------------------------------------------------------------------------------

my %config = (
    version         => 20120605,
    hasDescr        => 1,
    hasRefs         => 0,
	applyto			=> 'ios',
	srctype			=> "plist",
   	srcfile		    => "SystemVersion.plist",
   	srcpath		    => "/System/Library/CoreServices/",
);

sub getConfig       { return %config; }
sub getDescription  { return "Get the OS version"; }
sub getReferences   {}
sub getSourcePath   { return $config{srcpath}; }
sub getSourceFile   { return $config{srcfile}; }
sub getSourceType   { return $config{srctype}; }
sub getVersion      { return $config{version}; }
sub getApplyTo      { return $config{applyto}; }

#------------------------------------------------------------------------------
# helpers

my $VERSION = getVersion();
my $tab;
my $tab0 = '';
my $tab1 = '....';
my $tab2 = $tab1.$tab1;
my $tab3 = $tab1.$tab1.$tab1;
my $noalign = "%s";
my $align10 = "%-10s";
my $align15 = "%-15s";
my $align20 = "%-20s";
my $align25 = "%-25s";

#------------------------------------------------------------------------------

sub pluginmain {
	my $class = shift;
	my $plist = shift;
    my $tzone = shift;
	::logMsg("Launching iosVersion v.".$VERSION);
    die "Invalid PLIST object" if ( not defined $plist );

    my $key;
    my $val;
    my $align = $align25;

    $key = 'ProductName';
    $val = ::getPlistKeyValue( $plist, $key );
    $val = 'Not found' if not defined $val;
    ::rptMsg(sprintf($tab."$align = %s", $key, $val));
    
    $key = 'ProductVersion';
    $val = ::getPlistKeyValue( $plist, $key );
    $val = 'Not found' if not defined $val;
    ::rptMsg(sprintf($tab."$align = %s", $key, $val));

    $key = 'ProductUserVisibleVersion';
    $val = ::getPlistKeyValue( $plist, $key );
    $val = 'Not found' if not defined $val;
    ::rptMsg(sprintf($tab."$align = %s", $key, $val));
    
    $key = 'ProductBuildVersion';
    $val = ::getPlistKeyValue( $plist, $key );
    $val = 'Not found' if not defined $val;
    ::rptMsg(sprintf($tab."$align = %s", $key, $val));
    
    $key = 'ProductCopyright';
    $val = ::getPlistKeyValue( $plist, $key );
    $val = 'Not found' if not defined $val;
    ::rptMsg(sprintf($tab."$align = %s", $key, $val));
}

#------------------------------------------------------------------------------
1;